import React, { Component } from 'react';
import '.././tuijian.scss';
import { Link } from 'react-router-dom';

class Com extends Component {
    constructor (props) {
      super(props)
      this.state = {
          zmsrlist:[]
      }
    }
    componentDidMount () {
        fetch('http://poem.daxunxun.com:8000/api/juzi')
        .then(res => res.json())
        .then(data => {
          this.setState({
            zmsrlist:data
          })
        })
    }

    render () {
        return(
            <div className = "zmtop">
                <h2>著名诗人</h2>
                <ul> 
                    {
                        this.state.zmsrlist.map((item,index) => {
                            return(
                                <li key={index} onClick={this.handle}>
                                    <Link to="/zuozhe">
                                        <img src={item.autorpictures} alt=""/>
                                        <p>{item.name}</p>
                                    </Link>
                                </li>  
                            )
                           
                        })
                    }
                </ul>
            </div>
        )
    }
}

export default Com;